package org.lakesidecdc.outreach.server;

import javax.jdo.annotations.IdGeneratorStrategy;
import javax.jdo.annotations.IdentityType;
import javax.jdo.annotations.PersistenceCapable;
import javax.jdo.annotations.Persistent;
import javax.jdo.annotations.PrimaryKey;

import org.lakesidecdc.outreach.client.EventList;
import org.lakesidecdc.outreach.client.ProjectEvent;

@PersistenceCapable(identityType = IdentityType.APPLICATION)
public class ProjectData {

	@PrimaryKey
	@Persistent(valueStrategy = IdGeneratorStrategy.IDENTITY)
	private Long id;
	@Persistent
	private String name;
	@Persistent
	private String description;
	@Persistent
	private int referrals;
	@Persistent
	private EventList events;
	@Persistent
	private String email;
	
	public ProjectData(String name, String description) {
		this.name = name;
		this.description = description;
		this.referrals = 0;
		this.events = new EventList();
	}
	
	public ProjectData(String name, String description, String email) {
		this(name, description);
		this.email = email;
	}
	
	public void addEvent(ProjectEvent event) {
		if(!events.contains(event)) {
			events.add(event);
		}
	}
	
	public EventList getEvents() {
		return events;
	}

	public String getName() {
		return name;
	}

	public String getDescription() {
		return description;
	}

	public int getReferrals() {
		return referrals;
	}
	
	public float getVolunteerHours() {
		return events.getTotalVolunteerHours();
	}
	
	public float getStaffHours() {
		return events.getTotalStaffHours();
	}
	
	public double getCost() {
		return events.getTotalCost();
	}
	
	public float getEfficiency() {
		return 0;
	}

	public void setName(String name) {
		this.name = name;
	}

	public void setDescription(String description) {
		this.description = description;
	}

	public void setReferrals(int referrals) {
		this.referrals = referrals;
	}
	
	public EventList getEventList() {
		return events;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getEmail() {
		return email;
	}

	public Long getId() {
		return id;
	}
}
